﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Radiation___IM.ApiCommands
{
    public class ChannelsList : ICommand
    {
        private readonly string m_commandkey = "channels.list";

        public ChannelsList()
        {
        }

        public string commandKey()
        {
            return m_commandkey;
        }

        public string requiredPermission()
        {
            return null;
        }

        public void execute(string[] commands, Client client)
        {
            StringBuilder channels = new StringBuilder();

            foreach (Channel chan in ChannelManager.Instance.Channels.Values)
                channels.Append(chan.Name + ",");

            MessageExecution.sendDataAPI(client, channels.ToString().Substring(0, channels.ToString().Length - 1), commands[1]);
        }
    }
}
